package com.jerry.mingxing.ui.fashionrecommend;

import android.os.Handler;

import com.jerry.mingxing.bean.LabelBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2016/8/31.
 */
public class FashionRecommendPresenter implements FashionRecommendContract.Presenter{
    private FashionRecommendContract.Mode mode;
    private FashionRecommendContract.View view;

    public FashionRecommendPresenter(FashionRecommendContract.View view){
        this.view = view;
        this.mode = new FashionRecommendMode();
    }

    @Override
    public void getData() {
        mode.loalabelBrand(new Callback<LabelBean>() {
            @Override
            public void onResponse(Call<LabelBean> call, Response<LabelBean> response) {
                if (response.isSuccessful()){
                    final LabelBean body = response.body();
                    Handler handler = new Handler();
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            view.onResponse1(body);
                        }
                    });
                }
            }

            @Override
            public void onFailure(Call<LabelBean> call, Throwable t) {
                Handler handler = new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                      view.onFailure("加载失败");
                    }
                });
            }
        });

    }
}
